import { userInfoType, updateUserInfoParams } from "@/types/user";
import { ResetPasswordParams, ResetEmaiParams } from "@/types/user";
import { http } from "@/utils/request";

/**
 *  获取用户信息
 * @returns userInfoType
 */
export const getUserInfoAPI = () => {
  return http<userInfoType>({
    method: "GET",
    url: "/api/v1/users/getUserInfo",
  });
};

/**
 * 修改用户密码
 * @param data - 包含新密码的参数
 * @returns 返回API响应结果
 */
export const modifyPasswordAPI = (data: ResetPasswordParams) => {
  return http<string>({
    url: "/api/v1/users/resetPassword",
    method: "POST",
    header: {
      "Content-Type": "application/x-www-form-urlencoded;charset=UTF-8",
    },
    data,
  });
};

/**
 * 修改用户邮箱
 * @param data - 包含新邮箱的参数
 * @returns 返回API响应结果
 */
export const modifyEmailAPI = (data: ResetEmaiParams) => {
  return http<string>({
    url: "/api/v1/users/resetEmail", // 修改邮箱的API接口
    method: "POST",
    header: {
      "Content-Type": "application/x-www-form-urlencoded;charset=UTF-8",
    },
    data,
  });
};

//修改个人信息
export const modifyUserInfoAPI = (data: updateUserInfoParams) => {
  return http<string>({
    url: "/api/v1/users/changeUserInfo", // 修改个人信息的API接口
    method: "POST",
    data,
  });
};
